package com.cn.icss.controller;

import com.alibaba.fastjson.JSONObject;
import com.cn.icss.service.IThumbUpService;
import com.cn.icss.service.impl.ThumbUpServiceImpl;
import com.cn.icss.validator.ThumbUpValidator;
import com.cn.icss.vo.common.ResponseCode;
import com.cn.icss.vo.common.ResponseResult;
import com.cn.icss.vo.common.ResponseStatus;
import com.jfinal.aop.Before;
import com.jfinal.aop.Inject;
import com.jfinal.core.Controller;
import com.jfinal.ext.interceptor.POST;
import live.autu.plugin.jfinal.swagger.annotation.Api;
import live.autu.plugin.jfinal.swagger.annotation.ApiImplicitParam;
import live.autu.plugin.jfinal.swagger.annotation.ApiImplicitParams;
import live.autu.plugin.jfinal.swagger.annotation.ApiOperation;
import live.autu.plugin.jfinal.swagger.config.RequestMethod;
import org.apache.log4j.Logger;


/**
 * @中软华腾软件系统有限公司,未经授权不得擅自传播
 * @类描述:
 * @类名称:StreamController
 * @作者: Administrator
 * @编辑时间: 2020/04/08 12:55
 * @版本: 1.0
 */
@Api(description = "点赞接口",hidden = true)
public class ThumbUpController extends Controller {

    @Inject(ThumbUpServiceImpl.class)
    private IThumbUpService thumbUpService;
    Logger logger = Logger.getLogger(ThumbUpController.class);
    /**
    *@中软华腾软件系统有限公司,未经授权不得擅自传播
    *@方法描述: 查询点赞
    *@方法参数描述:
    ** @param
    *@作者: 蒋正午
    *@编辑时间: 2020/04/20  10:45
    *@返回值描述: void
    */
    @ApiOperation(methods= RequestMethod.POST)
    @ApiImplicitParams({
            @ApiImplicitParam(name="key",required=true, description="房间号或者小视频编号")
    })
    @Before({POST.class, ThumbUpValidator.class})
    public void queryThumbUp(){
        // 验证通过正常开发逻辑
        String key = getPara("key");
        // 调用后端业务层方法完成赞的查询
        Object result = this.thumbUpService.queryThumbUp(key);
        ResponseResult responseResult = ResponseResult.build(ResponseCode.OK, "查询成功", ResponseStatus.SUCCESS,result);
        renderJson(JSONObject.toJSONString(responseResult));
    }


    /**
    *@中软华腾软件系统有限公司,未经授权不得擅自传播
    *@方法描述: 点赞
    *@方法参数描述:
    ** @param
    *@作者: 蒋正午
    *@编辑时间: 2020/04/20  10:45
    *@返回值描述: void
    */
    @ApiOperation(methods= RequestMethod.POST)
    @ApiImplicitParams({
            @ApiImplicitParam(name="key",required=true, description="房间号或者小视频编号")
    })
    @Before({POST.class,ThumbUpValidator.class})
    public void thumbUpPlus(){
        String key = getPara("key");
        thumbUpService.thumbUpPlus(key);
        ResponseResult responseResult = ResponseResult.ok();
        renderJson(JSONObject.toJSONString(responseResult));
    }

    /**
    *@中软华腾软件系统有限公司,未经授权不得擅自传播
    *@方法描述: 取消点赞
    *@方法参数描述:
    ** @param
    *@作者: 蒋正午
    *@编辑时间: 2020/04/20  10:51
    *@返回值描述: void
    */
    @ApiOperation(methods= RequestMethod.POST)
    @ApiImplicitParams({
            @ApiImplicitParam(name="key",required=true, description="房间号或者小视频编号")
    })
    @Before({POST.class,ThumbUpValidator.class})
    public void thumbUpMinus(){
        String key = getPara("key");
        thumbUpService.thumbUpMinus(key);
        ResponseResult responseResult = ResponseResult.ok();
        renderJson(JSONObject.toJSONString(responseResult));
    }

    /**
    *@中软华腾软件系统有限公司,未经授权不得擅自传播
    *@方法描述: 清空点赞
    *@方法参数描述:
    ** @param
    *@作者: 蒋正午
    *@编辑时间: 2020/05/12  11:30
    *@返回值描述: void
    */
    @ApiOperation(methods= RequestMethod.POST)
    @ApiImplicitParams({
            @ApiImplicitParam(name="key",required=true, description="房间号或者小视频编号")
    })
    @Before({POST.class,ThumbUpValidator.class})
    public void clearThumbUp(){
        String key = getPara("key");
        thumbUpService.clearThumbUp(key);
        ResponseResult responseResult = ResponseResult.ok();
        renderJson(JSONObject.toJSONString(responseResult));
    }



}
